/*
    评论模块相关api
*/
var express = require("express");
var router = express.Router();
const parseUrl = require('url');
var queryString = require("querystring")

let comment = require("../controller/comment")

//添加评论
router.post('/addComment', (req, res) => {
    const data = req.body;
    comment.addComment(data).then((result, err) => {
        if (err) {
            res.send(err)
            return
        }
        console.log(result);
        res.send('ok')
    })
})

//根据博文id获取评论列表
router.get('/getCommentList', (req, res) => {
    const blogId = req.query.blogId
    comment.getCommentList(blogId).then(data => {
        res.send(JSON.stringify(data))
    })
})

module.exports = router